% Function : read label information from json file
% Parameter:
%   file: file path of json file(string)
% Return:
%   Eddy: labels of Eddy(cell of string)
%   Temp: labels of Temp(cell of string)
function [Eddy, Temp] = getLegend(file)
    Eddy = cell(0, 1);
    Temp = cell(0, 1);
    % open file and read json string
    fid  = fopen(file, 'r', 'n', 'UTF-8');
    json = fgetl(fid);
    fclose(fid);

    % parse json string
    [data, json] = parse_json(json);

    % pick out the eddy legend
    EddSenPos = data{1}.EddSenPos;
    n         = numel(EddSenPos);
    k         = 1;
    for i = 1 : n
        if ~strcmp(EddSenPos{i}, 'invalid')
            Eddy{k} = EddSenPos{i};
            k       = k + 1;
        end
    end

    % pick out the temperature legend
    Modules = data{1}.Modules;
    n       = numel(Modules);
    k       = 1;
    for i = 1 : n
        TemSenPos = Modules{i}.TemSenPos;
        m = numel(TemSenPos);
        for j = 1:m
            if ~strcmp(TemSenPos{j}, 'invalid')
                Temp{k} = TemSenPos{j};
                k       = k + 1;
            end
        end
    end
end
